home *** CD-ROM | disk | FTP | other *** search
- /* FastNet Box 2 */
- /* Data Layer routines */
-
- #define SCSI_MASTER
-
- #include <stdio.h>
-
- #include <Dialogs.h>
- #include <SCSI.h>
-
- #include "BoxLayer.h"
- #include "configrec.h"
- #include "maclook.h"
-
- #define RouterProtocol 0x6003
-
-
- unsigned int decAddr;
-
- unsigned char nodeAddress[6]= {0x08,0x00,0x89,0xf0,0x05,0xaf};
- unsigned char allRouters[6]= {0xAB,0x00,0x00,0x03,0x00,0x00};
- unsigned char allEndnodes[6]= {0xAB,0x00,0x00,0x04,0x00,0x00};
-
- unsigned char cmdCommand[CMD_LENGTH]= {SENDING_COMMAND,0};
- unsigned char reqCommand[CMD_LENGTH]= {REQUEST_DATA,0};
- unsigned char sendCommand[CMD_LENGTH]= {SENDING_DATA,0};
- unsigned char addrCommand[CMD_LENGTH]= {REQUEST_ADDR,0};
- char temp[50];
-
- void DoBoxCommand
- (
- void *theBufferPtr,
- int theLength
- )
- {
- SCSIInstr tibBlock[2];
- short status,message;
- while(SCSIGet()); /* Arbitration */
- while(SCSISelect(SCSI_ID)); /* Selection */
- SCSICmd(&cmdCommand[0],CMD_LENGTH); /* Command */
- tibBlock[0].scOpcode=scNoInc;
- tibBlock[0].scParam1=(long)theBufferPtr;
- tibBlock[0].scParam2=(long)theLength;
- tibBlock[1].scOpcode=scStop;
- tibBlock[1].scParam1=0;
- tibBlock[1].scParam2=0;
- SCSIWrite((Ptr) tibBlock); /* Data */
- SCSIComplete(&status,&message,60L); /* Completion */
- }
-
- int DoBoxAddrRequest
- (
- unsigned char *theBufferPtr
- )
- {
- SCSIInstr tibBlock[3];
- short status,message;
-
- putln("in box request");
- while(SCSIGet()); /* Arbitration */
- while(SCSISelect(SCSI_ID)); /* Selection */
- SCSICmd(&addrCommand[0],CMD_LENGTH); /* Command */
- putln("Command called ");
- tibBlock[0].scOpcode=scNoInc;
- tibBlock[0].scParam1=(long)theBufferPtr;
- tibBlock[0].scParam2=(long)6; /* Fixed length - 6 bytes */
- tibBlock[1].scOpcode=scStop;
- tibBlock[1].scParam1=0;
- tibBlock[1].scParam2=0;
- putln("Calling Read");
- SCSIRead((Ptr) tibBlock); /* Data */
- putln("Calling completion");
- SCSIComplete(&status,&message,60L); /* Completion */
- putln("Done....");
- return(status);
- }
-
- int DoBoxDataRequest /* Returns packet length or zero */
- (
- void *theBufferPtr
- )
- {
- SCSIInstr tibBlock[3];
- short status,message;
- while(SCSIGet()); /* Arbitration */
- while(SCSISelect(SCSI_ID)); /* Selection */
- SCSICmd(&reqCommand[0],CMD_LENGTH); /* Command */
- tibBlock[0].scOpcode=scNoInc;
- tibBlock[0].scParam1=((long)&tibBlock[1].scParam2)+2;
- tibBlock[0].scParam2=(long)2;
- tibBlock[1].scOpcode=scNoInc;
- tibBlock[1].scParam1=(long)theBufferPtr;
- tibBlock[1].scParam2=0; /* Length of data */
- tibBlock[2].scOpcode=scStop;
- tibBlock[2].scParam1=0;
- tibBlock[2].scParam2=0;
- SCSIRead((Ptr) tibBlock); /* Data */
- SCSIComplete(&status,&message,60L); /* Completion */
- return(tibBlock[1].scParam2);
- }
-
-
- void DoBoxDataSend
- (
- void *theBufferPtr,
- int theLength
- )
- {
- SCSIInstr tibBlock[3];
- short status,message;
- while(SCSIGet()); /* Arbitration */
- while(SCSISelect(SCSI_ID)); /* Selection */
- SCSICmd(&sendCommand[0],CMD_LENGTH); /* Command */
- tibBlock[0].scOpcode=scNoInc;
- tibBlock[0].scParam1=(long)&theLength;
- tibBlock[0].scParam2=(long)2;
- tibBlock[1].scOpcode=scNoInc;
- tibBlock[1].scParam1=(long)theBufferPtr;
- tibBlock[1].scParam2=(long)theLength;
- tibBlock[2].scOpcode=scStop;
- tibBlock[2].scParam1=0;
- tibBlock[2].scParam2=0;
- SCSIWrite((Ptr) tibBlock); /* Data */
- SCSIComplete(&status,&message,60L); /* Completion */
- }
-
-
- InitializeDataLayer(address)
- unsigned int address;
- {
- DataLinkData lanceData;
-
- /* Initialize address globals (DEC and EtherNet forms) */
- decAddr=address;
- nodeAddress[4]=address; /* LSB */
- nodeAddress[5]=address>>8; /* MSB */
-
- lanceData.promiscuousEnable=0;
- lanceData.protocolCount=1;
- lanceData.protocolType[0]=RouterProtocol;
- lanceData.multicastCount=0;
- lanceData.broadcastEnable=1;
-
- DoBoxCommand(&lanceData,sizeof(DataLinkData));
- }
-